package com.sqstudio.view
{
	import com.sqstudio.common.Sys;
	import com.sqstudio.common.TipManager;
	import com.sqstudio.ui.YiJiMC;
	import com.sqstudio.ui.YiJiTip;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class YiJiPanel extends Sprite
	{
		private var _yijiMc:YiJiMC;
		private var _yiTip:YiJiTip;
		private var _jiTip:YiJiTip;
		public function YiJiPanel()
		{
			this._yijiMc = new YiJiMC();
			addChild(this._yijiMc);
			var txtArr:Array = [_yijiMc.y1,_yijiMc.y2,_yijiMc.y3,_yijiMc.j1,_yijiMc.j2,_yijiMc.j3];
			for each(var txt:TextField in txtArr ){
				txt.mouseEnabled = txt.selectable = false;
			}
			
			this._yiTip = new YiJiTip();
			Sys.STAGE.addChild(this._yiTip);
			this._jiTip = new YiJiTip();
			Sys.STAGE.addChild(this._jiTip);
			
			new TipManager(this._yijiMc.yi_mc,this._yiTip,-10,-20);
			new TipManager(this._yijiMc.ji_mc,this._jiTip,-10,-20);
		}
		
		public function updateYiJiName($data:Array):void{
			var yiArr:Array = [_yijiMc.y1,_yijiMc.y2,_yijiMc.y3];
			var jiArr:Array = [_yijiMc.j1,_yijiMc.j2,_yijiMc.j3];
			var yTxtArr:Array = [this._yiTip.h1_txt,this._yiTip.h2_txt,this._yiTip.h3_txt,this._yiTip.h4_txt,this._yiTip.h5_txt];
			var jTxtArr:Array = [this._jiTip.h1_txt,this._jiTip.h2_txt,this._jiTip.h3_txt,this._jiTip.h4_txt,this._jiTip.h5_txt];
			
			var tmpTxt:Array = yiArr.concat(yiArr).concat(yTxtArr).concat(jTxtArr).concat(jiArr);
			for each(var txt1:TextField in tmpTxt){
				txt1.text="";
			}
			
			if($data.length==0) return;
			
			var yiMin:int = Math.min(yiArr.length,$data[0].length);
			for(var i:int=0;i<yiMin;i++){
				yiArr[i].text = $data[0][i];
			}
			var jiMin:int = Math.min(jiArr.length,$data[1].length);
			for(var j:int=0;j<jiMin;j++){
				jiArr[j].text = $data[1][j];
			}
			
			if($data[0].length>3){
				this._yiTip.alpha=1;
				var yiTipMin:int = Math.min(5,$data[0].length);
				for(var m:int=0;m<yiTipMin;m++){
					yTxtArr[m].text = $data[0][m];
				}
				this._yiTip.yjName.text = "宜";
			}else{
				this._yiTip.alpha=0;
			}
			
			if($data[1].length>3){
				this._jiTip.alpha=1;
				var jiTipMin:int = Math.min(5,$data[1].length);
				for(var n:int=0;n<jiTipMin;n++){
					jTxtArr[n].text = $data[1][n];
				}
				this._jiTip.yjName.text = "忌";
			}else{
				this._jiTip.alpha=0;
			}
		}
	}
}